(function (n, M, K) {
    n.fn.extend({
        A: function (f, e, P, t) {
            return this.stop().animate(f, e, P, t)
        },
        B: function (b) {
            return this.addClass(b)
        },
        C: function (b) {
            return this.removeClass(b)
        },
        E: function (b) {
            return this.hasClass(b)
        },
        G: function (e, d, f) {
            return this.fadeOut(e, d, f)
        },
        M: function (b) {
            return this.find(b)
        },
        L: function (b) {
            return this.removeAttr(b)
        },
        _G: function (b) {
            return this.trigger(b)
        }
    });
    var J = {
        c: "setTimeout",
        d: "clearTimeout",
        g: "width",
        h: "height",
        i: "outerWidth",
        j: "outerHeight",
        p: "scrollTop",
        q: "offset",
        u: "easeOutQuart",
        a: "scroll"
    }, H = {
            wd: n(M),
            ws: n("#dcm_wrap-outer-scrollable"),
            wo: n("#dcm_wrap-outer"),
            ass: n(".dcm_ass"),
            gr: n(".dcm_ass .gear"),
            wf: n("#dcm_wrap-footer"),
            tl: n("#dcm_last-comment")
        }, G = false,
        O = H.wd[J.g]() <= 700,
        m = null,
        p = {
            d: H.wo[J.j]() - H.wf[J.j]()
        };
    H.ws.on("scroll resize", function () {
        var b = n(this),
            a = b[J.p]();
        M[J.d](m);
        if (G === false) {
            m = M[J.c](function () {
                if (H.ass.E("on")) {
                    H.ass.A({
                        top: a + 200
                    }, {
                        duration: 3000,
                        easing: J.u,
                        step: function (c, d) {
                            H.gr.css("background-position", "50% -" + c + "px")
                        },
                        complete: function () {
                            var c = n(".tooltip", this);
                            c.C("push");
                            if (c[J.j]() + c[J.q]().top >= H.wd[J.h]()) {
                                c.B("push")
                            }
                        }
                    })
                }
                O = b[J.g]() <= 700;
                p.d = H.wo[J.j]() - H.wf[J.j]()
            }, 200)
        }
        H.tl.css("margin-bottom", (a + H.wd[J.h]()) >= p.d ? a + (H.wd[J.h]()) - p.d : 0)
    });
    var cA = n(".dcm_last-comment");
    cA.append('<ul class="comment-x-post"/>');
    var cq = n(".comment-x-post"),
        a4 = n("li.items-cmx");
    cq.html(a4);
    var a = n('.rcd'),
        b = n('.close'),
        c = n('#recent-comment-disqus'),
        d = n('.recent-comment-disqus').ts();
    a.removeAttr("href").click(function () {
        c.show("slow", function () {
            d.ts_u()
        })
    });
    b.click(function () {
        c.hide("slow")
    });
    var a = n(".dcm_form-comment-message");
    a.each(function () {
        n(this).append('<div class="copy-code" id="copy-code"></div>');
    });
    a.children('dcopy').wrapInner(function () {
        return '<a class="dcopy" title="Klik untuk menyalin kode ini" href="#"></a>';
    });
    var b = n("a.dcopy");
    b.on("click", function () {
        var pl = n("#copy-code").show(),
            ot = n(this).parent().find('kodec').html();
        pl.html('<textarea style="width:285px;height:40px;" spellcheck="false">' + ot + '</textarea><scr' + 'ipt type="text/javascript">var a=document.getElementsByTagName(\'textarea\')[0];a.focus();a.select();</scr' + 'ipt>');
        pl.append('<a href="#close" class="close" title="Tutup" onclick="document.getElementById(&#39;copy-code&#39;).removeAttribute(&#39;style&#39;);return false;"><span class="sr">Tutup</span></a>')
        return false;
    });
    n("li.button-n").each(function () {
        $(this).append('<span class="counter-text"><div class="loading"/></span>');
        var c = n(this);
        var b = c.attr("id");
        var a = new Firebase("https://dcm404.firebaseio.com/" + b);
        a.on("value", function (d) {
            var f = d.val();
            if (f == null) {
                a.set(0);
                c.find(".counter-text").html(0).attr('title', 'Jumlah klik 0');
                c.find(".dcm_Demo,.dcm_Download,.dcm_link").attr('title', 'Belum pernah ada yang mengklik tombol ini')
            } else {
                c.find(".counter-text").html(f).attr('title', 'Jumlah klik ' + f + '');
                c.find(".dcm_Demo,.dcm_Download,.dcm_link").attr('title', 'Tombol ini sudah di klik sebanyak ' + f + ' kali')
            }
        });
        c.children("a").click(function () {
            var d = parseInt($(this).siblings(".counter-text,.dcm_Demo,.dcm_Download,.dcm_link").text());
            d++;
            a.set(d)
        })
    });
    n.each(n("a[name]"), function (a, d) {
        var c = n(d).parent().find(".statistic");
        var b = new Firebase("https://dcm404.firebaseio.com/pages/id/" + n(d).attr("name"));
        b.once("value", function (f) {
            var h = f.val();
            var g = false;
            if (h == null) {
                h = {};
                h.value = 0;
                h.url = window.location.href;
                h.id = $(d).attr("name");
                g = true
            }
            c.html(h.value);
            h.value++;
            if (window.location.pathname != "/") {
                if (g) {
                    b.set(h)
                } else {
                    b.child("value").set(h.value)
                }
            }
        })
    })
})(jQuery, window, document);
